
* Set directories
*cd /Users/xiaosongw/Dropbox/Research/InformedSources/Stata/Analysis
*local datdir /Users/xiaosongw/Dropbox/Research/InformedSources/Replication/Build/Output/

cd /Users/byrned/Dropbox/Research/InformedSources/Replication/Analysis
local datdir /Users/byrned/Dropbox/Research/InformedSources/Replication/Build/Output/


*--------------- Figure 9a: Daily Volume Share in Melbourne ------------------*

* Load volume share data
use `datdir'volshare_daily, clear
qui sum t, detail
local min_t=r(min)
local max_t=r(max)
sort t
save Temp/temp, replace

* Merge in price data
use `datdir'is_mel_p_2005_2019, clear
keep if t>=`min_t' & t<=`max_t'
sort t
collapse(mean) p, by(t)
merge 1:1 t using Temp/temp, nogen

* Create graph 
local panel1=td(4jul2016)
local panel2=td(27jul2016)
twoway 	(line p t, yaxis(1) lwidth(medium) lcolor(gs0) connect(stairstep) lpattern(solid) ///
		ytitle("Mean Station-Level Gasoline Price (cpl)", axis(1)) ///
		ylabel(100(10)140,labsize(*0.8) axis(1))) ///
		(line volshare t, yaxis(2) lwidth(medthick) lcolor(gs8) connect(stairstep) lpattern(dash) ///
		xtitle("Date") ///
		ytitle("Share of Gasoline Volume Sold (%)", axis(2)) ///
		xlabel(20636 `" "Jul 1"   "2016" "' ///
			   20667 `" "Aug 1"   "2016" "' ///  
			   20698 `" "Sep 1"   "2016" "' ///
			   20728 `" "Oct 1"   "2016" "', labsize(*0.8)) ///
		ylabel(2(0.5)4.5, labsize(*0.8) axis(2) grid) ///
		legend(ring(0) size(*0.7) position(1) symx(*0.25) region(lwidth(*0.05)) rows(2) ///
		label(1 "Mean Station-Level Gasoline Price") label(2 "Share of Gasoline Volume Sold")) ///
		plotregion(margin(zero) style(none) fcolor(white)) graphregion(fcolor(white)) ///
		text(140.5 `panel1' "{bf:A}", justification(left) size(*2)) ///
		text(140.75 `panel2' "       Daily Gasoline Sales Shares", justification(left) size(*1.25)))
graph export Output/fig9a_volshare.pdf, as(pdf) replace

*----------------- Figure 9b: Monthly Consumption in Melbourne ---------------*

* Load data
use `datdir'voltot_monthly, clear
keep if month>=tm(2015m6) & month<=tm(2018m6)


* Create graph 
local panel1=tm(2015m7)
local panel2=tm(2016m4)
twoway (line voltot month, lwidth(medium) lcolor(gs0) ///
		ytitle("Total Volume of Gasoline Sold (Mega Liters)") xtitle("Month") ///
		xlabel(665 `" "June"   "2015" "' ///
			   677 `" "June"   "2016" "' ///  
			   689 `" "June"   "2017" "' ///
			   701 `" "June"   "2018" "', labsize(*0.8)) ///
		ylabel(250(10)302,grid) ///
		plotregion(margin(zero) style(none) fcolor(white)) graphregion(fcolor(white)) ///
		text(302 `panel1' "{bf:B}", justification(left) size(*2)) ///
		text(302 `panel2' "       Monthly Gasoline Volumes Sold", justification(left) size(*1.2)))
graph export Output/fig9b_voltot.pdf, as(pdf) replace
